<?php
session_start();
?>
<!--/*验证码的session开始，如果不放在前面，有的服务器会出现警告*/-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php include '../controlbase/coresection/title.php'; ?></title>
<style type="text/css">
    html{ width: 100%; height: 100%;}
    body{
        padding: 0; margin: 0; position: relative; width: 100%; height: 100%;;
    }
    #loginform{ position: absolute; top: 50%; left: 50%; margin: -205px 0 0 -213px; text-align: center;}
    #loginform ul{ background: #FFF; width: 306px; height: 345px; box-shadow: #ccc 0px 0px 10px; margin: 0; padding: 65px 60px 0; list-style: none; overflow: hidden;}
    #loginform ul li{ border: #CCC 1px solid; padding: 10px 25px; overflow: hidden; margin-bottom: 25px;}
    #loginform ul li label{ height: 34px; width: 45px; float: left; border-right:#CCC 1px solid; }
    #loginform ul li .ico_1{ background: url("images/input_icon1.jpg") no-repeat left center;}
    #loginform ul li .ico_2{ background: url("images/input_icon2.jpg") no-repeat left center;}
    #loginform ul li .ico_3{ background: url("images/input_icon3.jpg") no-repeat left center;}
    #loginform ul li input{ border: none; height: 34px; padding: 0 5px; margin-left: 15px; width: 170px; float: left; color: #999;}
    #loginform ul li #submit{ background: #84b8f3; color: #FFF; width: 100%; margin: 0; padding: 0; height: 50px; font-size: 1.2em; font-family: "microsoft yahei"; cursor: pointer;}
</style>
</head>

<body>

<?
if(!isset($_REQUEST['username']) or $_REQUEST['username']=='')
{
	$_REQUEST['username']='';
	$_REQUEST['userpass']='';
}
?>


<form id="loginform" name="loginform" method="post" action="" enctype="multipart/form-data" >
    <ul>
        <li>
            <label class="ico_1"></label>
            <input name="username" type="text" class="input" id="username" alt="账号" value="<? echo $_REQUEST['username'] ?>" />
        </li>
        <li>
            <label class="ico_2"></label>
            <input name="userpass" type="password" class="input" id="userpass" alt="" value="<? echo $_REQUEST['userpass'] ?>" placeholder="密码"/>

        </li>
        <li style="width: 147px; float: left;">
            <label class="ico_3"></label>
            <input type="text" name="code" id="code" style="width: 73px;" alt="验证码">
        </li>
        <img src="../../application/verify/z_imgcode.php" onclick='this.src="../application/verify/z_imgcode.php?"+Math.random();' style="cursor:pointer; border:1px solid #CC9900; width: 95px; float: left; margin: 7px 0 0 10px;">
        <?php
        if(isset($_REQUEST['code'])){
            if($_REQUEST['code'] == strtolower($_SESSION['yzm'])){
                echo "
		<script type='text/javascript'>
		document.getElementById('loginform').action = 'logincheck.php';
        document.getElementById('loginform').submit();
		</script>";
            }else{
                echo '<script type="text/javascript"> alert("请输入正确的验证码！");</script>';
            }
        }
        ?>
        <li style="clear: both; border: none; padding: 0;">
            <input type="submit" name="submit" id='submit' value="登　陆" />
        </li>
    </ul>
     
</form>
<script language="javascript" type="text/javascript">
    window.onload = function(){


        function textInputFn(name){
            var o =document.getElementById(name);
            o.setAttribute("valueCache",o.value);

            //失去焦点的时候
            o.onblur = function(){
                if(o.value=="") {
                    document.getElementById(name).setAttribute("placeholder","密码");
                    o.valueCache="";
                    o.value=o.alt;

                } else {
                    o.valueCache=o.value;
                }
            };

            //获得焦点的时候
            o.onfocus = function(){
                document.getElementById(name).setAttribute("placeholder","");
                o.value=o.valueCache;
                var e = event.srcElement;
                var r =e.createTextRange();
                r.moveStart('character',e.value.length);
                r.collapse(true);
                r.select();


            };
            o.onblur();
        }



        textInputFn("username");
        textInputFn("userpass");
        textInputFn("code");

    }
</script>
</body>
</html>